Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf_hooks: allow omitted parameters in 'performance.measure' #32651

Closed
wants to merge 1 commit into from

Conversation

himself65
Copy link
Member

@himself65 himself65 commented Apr 4, 2020

FIxes: #32647
Refs: https://www.w3.org/TR/user-timing-2/#measure-method

const { PerformanceObserver, performance } = require('perf_hooks');

const obs = new PerformanceObserver((items) => {
  console.log(items.getEntries()[0].duration);
  performance.clearMarks();
});
obs.observe({ entryTypes: ['measure'] });
performance.measure('Start to Now');

performance.mark('A');
doSomeLongRunningProcess(() => {
  performance.measure('A to Now', 'A');

  performance.mark('B');
  performance.measure('A to B', 'A', 'B');
});
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. perf_hooks Issues and PRs related to the implementation of the Performance Timing API. labels Apr 4, 2020
@himself65 himself65 marked this pull request as ready for review April 4, 2020 10:22
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs a changes: entry for the documentation and tests.

doc/api/perf_hooks.md Outdated Show resolved Hide resolved
@himself65
Copy link
Member Author

This probably needs a changes: entry for the documentation and tests.

I have no idea how to add a test for these additions, any suggestions?

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs a changes: entry for the documentation and tests.

I have no idea how to add a test for these additions, any suggestions?

Not really, because it isn’t quite obvious to me what exactly these changes end up doing.

doc/api/perf_hooks.md Outdated Show resolved Hide resolved
@himself65
Copy link
Member Author

himself65 commented Apr 4, 2020

Not really, because it isn’t quite obvious to me what exactly these changes end up doing.

// test.js
const { PerformanceObserver, performance } = require('perf_hooks');

const obs = new PerformanceObserver((items) => {
  console.log(items.getEntries()[0].duration);
  performance.clearMarks();
});
obs.observe({ entryTypes: ['measure'] });

setTimeout(() => {
  performance.measure('Foo');
  performance.mark('B')
  performance.measure('to B', 'nodeStart', 'B');
}, 1000);
./Release/node.exe test.js
1029.4472
1033.832401

doc/api/perf_hooks.md Outdated Show resolved Hide resolved
@addaleax
Copy link
Member

addaleax commented Apr 4, 2020

@himself65 I guess that example could serve as the basis for a test then?

@himself65 himself65 force-pushed the 20200404-perf_hooks branch 3 times, most recently from bf42542 to b420270 Compare April 4, 2020 12:00
doc/api/perf_hooks.md Outdated Show resolved Hide resolved
doc/api/perf_hooks.md Outdated Show resolved Hide resolved
lib/perf_hooks.js Show resolved Hide resolved
@himself65 himself65 force-pushed the 20200404-perf_hooks branch 3 times, most recently from 0b38140 to f85faa4 Compare April 5, 2020 18:33
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with tests added 👍

lib/perf_hooks.js Outdated Show resolved Hide resolved
@himself65 himself65 force-pushed the 20200404-perf_hooks branch 2 times, most recently from e9ec51a to 25bd57d Compare April 6, 2020 15:30
lib/perf_hooks.js Outdated Show resolved Hide resolved
Make `startMark` and `endMark` parameters optional.
@nodejs-github-bot
Copy link
Collaborator

@himself65 himself65 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 9, 2020
@nodejs-github-bot
Copy link
Collaborator

@himself65 himself65 self-assigned this Apr 10, 2020
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@himself65
Copy link
Member Author

himself65 commented Apr 10, 2020

I think CI should all green but

image

They are old CI state, maybe some bug here

himself65 added a commit to himself65/node that referenced this pull request Apr 10, 2020
Make `startMark` and `endMark` parameters optional.

PR-URL: nodejs#32651
Fixes: nodejs#32647
Refs: https://www.w3.org/TR/user-timing-2/#measure-method
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@himself65
Copy link
Member Author

Landed in d0a3bf1

@himself65 himself65 closed this Apr 10, 2020
@himself65 himself65 deleted the 20200404-perf_hooks branch April 10, 2020 10:19
targos pushed a commit that referenced this pull request Apr 12, 2020
Make `startMark` and `endMark` parameters optional.

PR-URL: #32651
Fixes: #32647
Refs: https://www.w3.org/TR/user-timing-2/#measure-method
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BethGriggs pushed a commit that referenced this pull request Apr 14, 2020
Make `startMark` and `endMark` parameters optional.

PR-URL: #32651
Fixes: #32647
Refs: https://www.w3.org/TR/user-timing-2/#measure-method
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Apr 22, 2020
Make `startMark` and `endMark` parameters optional.

PR-URL: #32651
Fixes: #32647
Refs: https://www.w3.org/TR/user-timing-2/#measure-method
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. perf_hooks Issues and PRs related to the implementation of the Performance Timing API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

perf_hooks: measure() should allow endMark to be omitted
5 participants